using DiLu.Expansion.File.Operates.LocalDisk.Configs;

namespace DiLu.Expansion.File;

/// <summary>
///     本地磁盘扩展
/// </summary>
public static partial class DiLuFileExpansion
{
    /// <summary>
    ///     构建文件流保存到本地磁盘的配置
    /// </summary>
    /// <param name="fileStream">文件流</param>
    /// <param name="rootDirectory">根目录</param>
    /// <param name="fileGroupName">文件分组名称</param>
    /// <param name="fileExtension">文件扩展名</param>
    /// <returns></returns>
    public static SaveFileStreamToLocalDiskConfig BuildSaveFileStreamToLocalDiskConfig(this Stream fileStream,
        string rootDirectory, string fileGroupName, string fileExtension)
    {
        return new SaveFileStreamToLocalDiskConfig(rootDirectory, fileGroupName, fileStream, fileExtension);
    }

    /// <summary>
    ///     构建获取本地磁盘文件的配置
    /// </summary>
    /// <param name="rootDirectory">根目录</param>
    /// <param name="fileGroupName">文件分组名称</param>
    /// <param name="fileRelativePath">文件相对路径</param>
    /// <returns></returns>
    public static GetLocalDiskFileStreamConfig BuildGetLocalDiskFileConfig(this string fileRelativePath,
        string rootDirectory, string fileGroupName)
    {
        return new GetLocalDiskFileStreamConfig(rootDirectory, fileGroupName, fileRelativePath);
    }

    /// <summary>
    ///     构建获取本地磁盘文件的配置
    /// </summary>
    /// <param name="fileFullPath">文件完整路径</param>
    /// <returns></returns>
    public static GetLocalDiskFileStreamConfig BuildGetLocalDiskFileConfig(this string fileFullPath)
    {
        return new GetLocalDiskFileStreamConfig(fileFullPath);
    }

    /// <summary>
    ///     构建删除本地磁盘文件的配置
    /// </summary>
    /// <param name="rootDirectory">根目录</param>
    /// <param name="fileGroupName">文件分组名称</param>
    /// <param name="fileRelativePath">文件相对路径</param>
    /// <returns></returns>
    public static DeleteLocalDiskFileConfig BuildDeleteLocalDiskFileConfig(this string fileRelativePath,
        string rootDirectory, string fileGroupName)
    {
        return new DeleteLocalDiskFileConfig(rootDirectory, fileGroupName, fileRelativePath);
    }

    /// <summary>
    ///     构建删除本地磁盘文件的配置
    /// </summary>
    /// <param name="fileFullPath">文件完整路径</param>
    /// <returns></returns>
    public static DeleteLocalDiskFileConfig BuildDeleteLocalDiskFileConfig(this string fileFullPath)
    {
        return new DeleteLocalDiskFileConfig(fileFullPath);
    }

    /// <summary>
    ///     构建删除本地磁盘文件夹的配置
    /// </summary>
    /// <param name="rootDirectory">根目录</param>
    /// <param name="fileGroupName">文件分组名称</param>
    /// <param name="directoryRelativePath">目录相对路径</param>
    /// <returns></returns>
    public static DeleteLocalDiskFolderConfig BuildDeleteLocalDiskFolderConfig(this string rootDirectory,
        string fileGroupName, string directoryRelativePath)
    {
        return new DeleteLocalDiskFolderConfig(rootDirectory, fileGroupName, directoryRelativePath);
    }

    /// <summary>
    ///     构建删除本地磁盘文件夹的配置
    /// </summary>
    /// <param name="directoryFullPath">目录完整路径</param>
    /// <returns></returns>
    public static DeleteLocalDiskFolderConfig BuildDeleteLocalDiskFolderConfig(this string directoryFullPath)
    {
        return new DeleteLocalDiskFolderConfig(directoryFullPath);
    }

    /// <summary>
    ///     构建搜索本地磁盘文件夹的配置
    /// </summary>
    /// <param name="rootDirectory">根目录</param>
    /// <param name="fileGroupName">文件分组名称</param>
    /// <param name="directoryRelativePath">目录相对路径</param>
    /// <param name="searchOption">搜索选项</param>
    /// <param name="containsHideFile">包含隐藏文件</param>
    /// <param name="searchPattern">
    ///     模糊查询模式，* 表示匹配所有文件
    ///     如果想查询指定类型文件使用 *.png  *.txt...
    ///     如果想模糊查询文件使用  *name*.*
    /// </param>
    /// <returns></returns>
    public static SearchLocalDiskFileConfig BuildSearchLocalDiskFileConfig(this string rootDirectory,
        string fileGroupName, string directoryRelativePath,
        SearchOption searchOption = SearchOption.TopDirectoryOnly, bool containsHideFile = false, string searchPattern = "*")
    {
        return new SearchLocalDiskFileConfig(rootDirectory, fileGroupName, directoryRelativePath,
            searchOption, containsHideFile, searchPattern);
    }

    /// <summary>
    ///     构建搜索本地磁盘文件夹的配置
    /// </summary>
    /// <param name="directoryFullPath">目录完整路径</param>
    /// <param name="searchOption">搜索选项</param>
    /// <param name="containsHideFile">包含隐藏文件</param>
    /// <param name="searchPattern">
    ///     模糊查询模式，* 表示匹配所有文件
    ///     如果想查询指定类型文件使用 *.png  *.txt...
    ///     如果想模糊查询文件使用  *name*.*
    /// </param>
    /// <returns></returns>
    public static SearchLocalDiskFileConfig BuildSearchLocalDiskFileConfig(this string directoryFullPath,
        SearchOption searchOption = SearchOption.TopDirectoryOnly, bool containsHideFile = false, string searchPattern = "*")
    {
        return new SearchLocalDiskFileConfig(directoryFullPath, searchOption, containsHideFile, searchPattern);
    }
}